﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginecup.gameState.intro;
using Microsoft.Xna.Framework.Content;
using imaginecup.util;
using Microsoft.Xna.Framework;
using Imaginecup.sprite;
using Imaginecup.scroll;
using Microsoft.Xna.Framework.Graphics;
using Imaginecup.gameState.ending.unuse;

namespace Imaginecup.gameState.ending.scene5.unuse
{
    public class EndingScene5_1
    {
        private int m_InitY;        
        private SimpleDrawObject[] m_SimpleObject = new SimpleDrawObject[5];
        private ScrollMan[] m_ScrollMan = new ScrollMan[5];


        public EndingScene5_1()
        {
            m_InitY = 480 * 4;

            EntityInfo info = new EntityInfo(800, m_InitY, 309, 272);

            m_SimpleObject[0] = new SimpleDrawObject();
            m_SimpleObject[0].SetEntityInfo(info);

            info.mPosition.X += 80;
            info.mPosition.Y += 165;

            info.mSize = new Vector2(374, 234);

            m_SimpleObject[1] = new SimpleDrawObject();
            m_SimpleObject[1].SetEntityInfo(info);

            info.mPosition.X += 280;
            info.mPosition.Y += 95;

            info.mSize = new Vector2(418, 320);

            m_SimpleObject[2] = new SimpleDrawObject();
            m_SimpleObject[2].SetEntityInfo(info);

        }



        public void LoadEndingScene()
        {
            for (int i = 0; i < 3; i++)
            {
                NormalSprite sprite = new NormalSprite();
                sprite.SetTextureName("" + (i + 1));
                m_SimpleObject[i].SetSprite(sprite);

                m_ScrollMan[i] = new ScrollMan();
                m_ScrollMan[i].StopScroll();
            }


            m_ScrollMan[0].SetScrollProcess(new WidthRightScroll(0, 180, 800));
            m_ScrollMan[1].SetScrollProcess(new WidthRightScroll(0, 150, 800));
            m_ScrollMan[2].SetScrollProcess(new WidthRightScroll(0, 130, 800));
        }

        public void UnloadEndingScene()
        {
            for (int i = 0; i < 3; i++)
                m_SimpleObject[i].Release();
            m_SimpleObject = null;
            m_ScrollMan = null;
        }


        public void StartAnimation()
        {
            for (int i = 0; i < 3; i++ )
                m_ScrollMan[i].StartScroll();
        }

        public void Update(GameTime gameTime , ScrollMan scrollMan)
        {
            for (int i = 0; i < 3; i++)
            {
                m_SimpleObject[i].SubPositionToInit(new Vector2(m_ScrollMan[i].GetCurrentStartPos().X, scrollMan.GetCurrentStartPos().Y));
            }

            for (int i = 0; i < 3; i++ )
                m_ScrollMan[i].Update(gameTime);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            for (int i = 2; i >= 0; i-- )
            {
                m_SimpleObject[i].Draw(spriteBatch);
            }

        }

    }
}
